load("//pkg/sql/schemachanger/sctest/sctestgen:gen.bzl", "sctest_gen")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "schemachangerccl",
    srcs = ["doc.go"],
    importpath = "github.com/cockroachdb/cockroach/pkg/ccl/schemachangerccl",
    visibility = ["//visibility:public"],
)

filegroup(
    name = "end_to_end_ccl_testdata_definitions",
    srcs = glob(["testdata/end_to_end/*/*.definition"]),
    visibility = ["//visibility:public"],
)

go_test(
    name = "schemachangerccl_test",
    size = "enormous",
    srcs = [
        "main_test.go",
        "schemachanger_ccl_test.go",
        ":test_gen_backup_base",  # keep
        ":test_gen_ccl",  # keep
    ],
    data = glob(["testdata/**"]) + [
        "//pkg/sql/schemachanger:end_to_end_testdata",
    ],
    embed = [":schemachangerccl"],
    exec_properties = {"test.Pool": "large"},
    shard_count = 48,
    tags = ["cpu:3"],
    deps = [
        "//pkg/base",
        "//pkg/ccl",
        "//pkg/ccl/multiregionccl/multiregionccltestutils",
        "//pkg/jobs",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/server",
        "//pkg/sql",
        "//pkg/sql/schemachanger/scexec",
        "//pkg/sql/schemachanger/sctest",
        "//pkg/testutils/datapathutils",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/testcluster",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/randutil",
    ],
)

sctest_gen(
    name = "test_gen_backup_base",
    out = "backup_base_generated_test.go",
    ccl = True,
    new_cluster_factory = "sctest.SingleNodeTestClusterFactory{}",
    package = "schemachangerccl",
    suffix = "_base",
    test_data = ["//pkg/sql/schemachanger:end_to_end_testdata_definitions"],
    tests = [
        "BackupRollbacks",
        "BackupRollbacksMixedVersion",
        "BackupSuccess",
        "BackupSuccessMixedVersion",
    ],
    visibility = [
        ":__pkg__",
        "//pkg/gen:__pkg__",
    ],
)

sctest_gen(
    name = "test_gen_ccl",
    out = "ccl_generated_test.go",
    ccl = True,
    new_cluster_factory = "MultiRegionTestClusterFactory{}",
    package = "schemachangerccl",
    suffix = "_ccl",
    test_data = [":end_to_end_ccl_testdata_definitions"],
    tests = [
        "BackupRollbacks",
        "BackupRollbacksMixedVersion",
        "BackupSuccess",
        "BackupSuccessMixedVersion",
        "EndToEndSideEffects",
        "ExecuteWithDMLInjection",
        "GenerateSchemaChangeCorpus",
        "Pause",
        "PauseMixedVersion",
        "Rollback",
    ],
    visibility = [
        ":__pkg__",
        "//pkg/gen:__pkg__",
    ],
)
